package com.example.safeassistan.login.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.safeassistan.R;
import com.example.safeassistan.base.BaseActivity;


public class PrivacyActivity extends BaseActivity {
    private WebView webView;
    private String URL;
    private String title="";
    private int type=0;

    public static void actionStart(Context context,String title,int type ) {
        Intent intent = new Intent(context, PrivacyActivity.class);
        intent.putExtra("title",title);
        intent.putExtra("type",type);
        context.startActivity(intent);
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(false);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.activity_privacy;
    }

    private void setWebView(String url) {
        webView = findViewById(R.id.web_view);
        //加载网页

        WebSettings webSettings = webView.getSettings();
        //设置WebView属性，能够执行Javascript脚本
        webSettings.setJavaScriptEnabled(true);
        //设置可以访问文件
        webSettings.setAllowFileAccess(true);
        //设置支持缩放
        webSettings.setBuiltInZoomControls(true);
        webView.loadUrl(url);
        //设置Web视图
        //设置Web视图
        webView.setWebViewClient(new webViewClient());
    }

    //Web视图
    static class webViewClient extends WebViewClient {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
    @Override
    protected void initView() {
        type=getIntent().getIntExtra("type",0);
        title=getIntent().getStringExtra("title");
        setTitleText(title);
        URL="http://api.xof.cn/tzyH5/protocol.html?helpType=";
        setWebView(URL+type);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getTitleBarType() {
        return 0;
    }
}
